{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    " obj = pd.Series([4.5, 7.2, -5.3, 3.6], index=['d', 'b', 'a',\n",
    "'c'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "d    4.5\n",
       "b    7.2\n",
       "a   -5.3\n",
       "c    3.6\n",
       "dtype: float64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj2 = obj.reindex(list('abcde'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a   -5.3\n",
       "b    7.2\n",
       "c    3.6\n",
       "d    4.5\n",
       "e    NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    " obj3 = pd.Series(['blue', 'purple', 'yellow'], index=[0, 2,\n",
    "4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      blue\n",
       "2    purple\n",
       "4    yellow\n",
       "dtype: object"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      blue\n",
       "1      blue\n",
       "2    purple\n",
       "3    purple\n",
       "4    yellow\n",
       "dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj3.reindex(range(5),method='ffill')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame = pd.DataFrame(np.arange(9).reshape((3, 3)),\n",
    "index=['a', 'c', 'd'],\n",
    "columns=['Ohio', 'Texas',\n",
    "'California'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Ohio</th>\n",
       "      <th>Texas</th>\n",
       "      <th>California</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Ohio  Texas  California\n",
       "a     0      1           2\n",
       "c     3      4           5\n",
       "d     6      7           8"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame2 = frame.reindex(list('abcd'),method='ffill')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Ohio</th>\n",
       "      <th>Texas</th>\n",
       "      <th>California</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Ohio  Texas  California\n",
       "a     0      1           2\n",
       "b     0      1           2\n",
       "c     3      4           5\n",
       "d     6      7           8"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "states = ['Texas', 'Utah', 'California']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Texas</th>\n",
       "      <th>Utah</th>\n",
       "      <th>California</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Texas  Utah  California\n",
       "a      1   NaN           2\n",
       "b      1   NaN           2\n",
       "c      4   NaN           5\n",
       "d      7   NaN           8"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame2.reindex(columns=states)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "t = frame2.reindex(columns=states)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "t['a'] =1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Texas</th>\n",
       "      <th>Utah</th>\n",
       "      <th>California</th>\n",
       "      <th>a</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Texas  Utah  California  a\n",
       "a      1   NaN           2  1\n",
       "b      1   NaN           2  1\n",
       "c      4   NaN           5  1\n",
       "d      7   NaN           8  1"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Ohio</th>\n",
       "      <th>Texas</th>\n",
       "      <th>California</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Ohio  Texas  California\n",
       "a     0      1           2\n",
       "b     0      1           2\n",
       "c     3      4           5\n",
       "d     6      7           8"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series(np.arange(5.), index=['a', 'b', 'c', 'd',\n",
    "'e'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "b    1.0\n",
       "c    2.0\n",
       "d    3.0\n",
       "e    4.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "new_obj = obj.drop('c')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "b    1.0\n",
       "d    3.0\n",
       "e    4.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = pd.DataFrame(np.arange(16).reshape((4, 4)),\n",
    "index=['Ohio', 'Colorado', 'Utah', 'New York'],\n",
    "columns=['one', 'two', 'three',\n",
    "'four'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Ohio        0    1      2     3\n",
       "Colorado    4    5      6     7\n",
       "Utah        8    9     10    11\n",
       "New York   12   13     14    15"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Utah        8    9     10    11\n",
       "New York   12   13     14    15"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.drop(['Colorado', 'Ohio'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  three  four\n",
       "Ohio        0      2     3\n",
       "Colorado    4      6     7\n",
       "Utah        8     10    11\n",
       "New York   12     14    15"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.drop('two',axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  three  four\n",
       "Ohio        0      2     3\n",
       "Colorado    4      6     7\n",
       "Utah        8     10    11\n",
       "New York   12     14    15"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.drop(columns='two')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data.drop(columns='two',inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  three  four\n",
       "Ohio        0      2     3\n",
       "Colorado    4      6     7\n",
       "Utah        8     10    11\n",
       "New York   12     14    15"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    " obj = pd.Series(np.arange(4.), index=['a', 'b', 'c', 'd'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "b    1.0\n",
       "c    2.0\n",
       "d    3.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj['b']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "b    1.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj[obj < 2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b    1.0\n",
       "d    3.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj[[1,3]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b    1.0\n",
       "c    2.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj['b':'c']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj['b':'c'] = 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "b    5.0\n",
       "c    5.0\n",
       "d    3.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = pd.DataFrame(np.arange(16).reshape((4, 4)),\n",
    "index=['Ohio', 'Colorado', 'Utah', 'New York'],\n",
    "columns=['one', 'two', 'three',\n",
    "'four'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Ohio        0    1      2     3\n",
       "Colorado    4    5      6     7\n",
       "Utah        8    9     10    11\n",
       "New York   12   13     14    15"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Ohio         1\n",
       "Colorado     5\n",
       "Utah         9\n",
       "New York    13\n",
       "Name: two, dtype: int32"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['two']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Ohio        0    1      2     3\n",
       "Colorado    4    5      6     7"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Ohio        False\n",
       "Colorado     True\n",
       "Utah         True\n",
       "New York     True\n",
       "Name: three, dtype: bool"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['three'] > 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Colorado    4    5      6     7\n",
       "Utah        8    9     10    11\n",
       "New York   12   13     14    15"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['three'] > 5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "two      5\n",
       "three    6\n",
       "Name: Colorado, dtype: int32"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.loc['Colorado',['two','three']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "four    11\n",
       "one      8\n",
       "two      9\n",
       "Name: Utah, dtype: int32"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[2,[3,0,1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "one       8\n",
       "two       9\n",
       "three    10\n",
       "four     11\n",
       "Name: Utah, dtype: int32"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Ohio        0    1      2     3\n",
       "Colorado    4    5      6     7\n",
       "Utah        8    9     10    11\n",
       "New York   12   13     14    15"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>four</th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>11</td>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          four  one  two\n",
       "Colorado     7    4    5\n",
       "Utah        11    8    9"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[[1, 2], [3, 0, 1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Ohio        1\n",
       "Colorado    5\n",
       "Utah        9\n",
       "Name: two, dtype: int32"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " data.loc[:'Utah', 'two']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three\n",
       "Ohio        0    1      2\n",
       "Colorado    4    5      6"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[:,:3][data .three < 9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three\n",
       "Ohio        0    1      2\n",
       "Colorado    4    5      6\n",
       "Utah        8    9     10\n",
       "New York   12   13     14"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[:,:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Ohio        False\n",
       " Colorado     True\n",
       " Utah         True\n",
       " New York     True\n",
       " Name: three, dtype: bool]"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[data .three > 5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "      <th>three</th>\n",
       "      <th>four</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New York</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          one  two  three  four\n",
       "Ohio        0    1      2     3\n",
       "Colorado    4    5      6     7\n",
       "Utah        8    9     10    11\n",
       "New York   12   13     14    15"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[1,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ser = pd.Series(np.arange(3.))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ser2 = pd.Series(np.arange(3.), index=['a', 'b', 'c'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "b    1.0\n",
       "c    2.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser2[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0.0\n",
       "1    1.0\n",
       "2    2.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "s1 = pd.Series([7.3, -2.5, 3.4, 1.5], index=['a', 'c', 'd',\n",
    "'e'])\n",
    "s2 = pd.Series([-2.1, 3.6, -1.5, 4, 3.1],index=['a', 'c', 'e', 'f', 'g'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(a    7.3\n",
       " c   -2.5\n",
       " d    3.4\n",
       " e    1.5\n",
       " dtype: float64, a   -2.1\n",
       " c    3.6\n",
       " e   -1.5\n",
       " f    4.0\n",
       " g    3.1\n",
       " dtype: float64)"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1,s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    5.2\n",
       "c    1.1\n",
       "d    NaN\n",
       "e    0.0\n",
       "f    NaN\n",
       "g    NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 + s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    5.2\n",
       "c    1.1\n",
       "d    3.4\n",
       "e    0.0\n",
       "f    4.0\n",
       "g    3.1\n",
       "dtype: float64"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.add(s2,fill_value=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df1 = pd.DataFrame(np.arange(9.).reshape((3, 3)),\n",
    "columns=list('bcd'),\n",
    "index=['Ohio', 'Texas', 'Colorado'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df2 = pd.DataFrame(np.arange(12.).reshape((4, 3)),\n",
    "columns=list('bde'),\n",
    "index=['Utah', 'Ohio', 'Texas',\n",
    "'Oregon'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(            b    c    d\n",
       " Ohio      0.0  1.0  2.0\n",
       " Texas     3.0  4.0  5.0\n",
       " Colorado  6.0  7.0  8.0,           b     d     e\n",
       " Utah    0.0   1.0   2.0\n",
       " Ohio    3.0   4.0   5.0\n",
       " Texas   6.0   7.0   8.0\n",
       " Oregon  9.0  10.0  11.0)"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1,df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Colorado</th>\n",
       "      <td>6.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10.0</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>9.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            b    c     d     e\n",
       "Colorado  6.0  7.0   8.0   NaN\n",
       "Ohio      3.0  1.0   6.0   5.0\n",
       "Oregon    9.0  NaN  10.0  11.0\n",
       "Texas     9.0  4.0  12.0   8.0\n",
       "Utah      0.0  NaN   1.0   2.0"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.add(df2,fill_value=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df1 = pd.DataFrame(np.arange(12.).reshape((3, 4)),\n",
    "columns=list('abcd'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df2 = pd.DataFrame(np.arange(20.).reshape((4, 5)),\n",
    "columns=list('abcde'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df2.loc[1, 'b'] = np.nan"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     a    b     c     d\n",
       "0  0.0  1.0   2.0   3.0\n",
       "1  4.0  5.0   6.0   7.0\n",
       "2  8.0  9.0  10.0  11.0"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>19.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      a     b     c     d     e\n",
       "0   0.0   1.0   2.0   3.0   4.0\n",
       "1   5.0   NaN   7.0   8.0   9.0\n",
       "2  10.0  11.0  12.0  13.0  14.0\n",
       "3  15.0  16.0  17.0  18.0  19.0"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>13.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>18.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      a     b     c     d   e\n",
       "0   0.0   2.0   4.0   6.0 NaN\n",
       "1   9.0   NaN  13.0  15.0 NaN\n",
       "2  18.0  20.0  22.0  24.0 NaN\n",
       "3   NaN   NaN   NaN   NaN NaN"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 + df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>18.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>19.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      a     b     c     d     e\n",
       "0   0.0   2.0   4.0   6.0   4.0\n",
       "1   9.0   5.0  13.0  15.0   9.0\n",
       "2  18.0  20.0  22.0  24.0  14.0\n",
       "3  15.0  16.0  17.0  18.0  19.0"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.add(df2,fill_value=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>inf</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.125000</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.090909</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          a         b         c         d\n",
       "0       inf  1.000000  0.500000  0.333333\n",
       "1  0.250000  0.200000  0.166667  0.142857\n",
       "2  0.125000  0.111111  0.100000  0.090909"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1/df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>inf</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.125000</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.090909</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          a         b         c         d\n",
       "0       inf  1.000000  0.500000  0.333333\n",
       "1  0.250000  0.200000  0.166667  0.142857\n",
       "2  0.125000  0.111111  0.100000  0.090909"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.rdiv(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     a    b     c     d  e\n",
       "0  0.0  1.0   2.0   3.0  0\n",
       "1  4.0  5.0   6.0   7.0  0\n",
       "2  8.0  9.0  10.0  11.0  0"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.reindex(columns=df2.columns,fill_value=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "arr = np.arange(12.).reshape((3, 4))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.,  1.,  2.,  3.],\n",
       "       [ 4.,  5.,  6.,  7.],\n",
       "       [ 8.,  9., 10., 11.]])"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 1., 2., 3.])"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0.],\n",
       "       [4., 4., 4., 4.],\n",
       "       [8., 8., 8., 8.]])"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr - arr[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame = pd.DataFrame(np.arange(12.).reshape((4, 3)),\n",
    "columns=list('bde'),\n",
    "index=['Utah', 'Ohio', 'Texas',\n",
    "'Oregon'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>6.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>9.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          b     d     e\n",
       "Utah    0.0   1.0   2.0\n",
       "Ohio    3.0   4.0   5.0\n",
       "Texas   6.0   7.0   8.0\n",
       "Oregon  9.0  10.0  11.0"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>9.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          b    d    e\n",
       "Utah    0.0  0.0  0.0\n",
       "Ohio    3.0  3.0  3.0\n",
       "Texas   6.0  6.0  6.0\n",
       "Oregon  9.0  9.0  9.0"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame - frame.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "series2 = pd.Series(range(3), index=['b', 'e', 'f'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "      <th>f</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>3.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>6.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>12.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          b   d     e   f\n",
       "Utah    0.0 NaN   3.0 NaN\n",
       "Ohio    3.0 NaN   6.0 NaN\n",
       "Texas   6.0 NaN   9.0 NaN\n",
       "Oregon  9.0 NaN  12.0 NaN"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame + series2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "series3 = frame['d']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Utah       1.0\n",
       "Ohio       4.0\n",
       "Texas      7.0\n",
       "Oregon    10.0\n",
       "Name: d, dtype: float64"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "series3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          b    d    e\n",
       "Utah   -1.0  0.0  1.0\n",
       "Ohio   -1.0  0.0  1.0\n",
       "Texas  -1.0  0.0  1.0\n",
       "Oregon -1.0  0.0  1.0"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.sub(series3,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.,  1.,  2.],\n",
       "       [ 3.,  4.,  5.],\n",
       "       [ 6.,  7.,  8.],\n",
       "       [ 9., 10., 11.]])"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame = pd.DataFrame(np.random.randn(4, 3),\n",
    "columns=list('bde'),\n",
    "index=['Utah', 'Ohio', 'Texas',\n",
    "'Oregon'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.461568</td>\n",
       "      <td>1.144868</td>\n",
       "      <td>-0.023796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>-0.211013</td>\n",
       "      <td>-0.017584</td>\n",
       "      <td>0.775530</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>0.354119</td>\n",
       "      <td>0.695202</td>\n",
       "      <td>0.519504</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>-1.000656</td>\n",
       "      <td>-0.186399</td>\n",
       "      <td>-0.674042</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               b         d         e\n",
       "Utah    0.461568  1.144868 -0.023796\n",
       "Ohio   -0.211013 -0.017584  0.775530\n",
       "Texas   0.354119  0.695202  0.519504\n",
       "Oregon -1.000656 -0.186399 -0.674042"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.461568</td>\n",
       "      <td>1.144868</td>\n",
       "      <td>0.023796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>0.211013</td>\n",
       "      <td>0.017584</td>\n",
       "      <td>0.775530</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>0.354119</td>\n",
       "      <td>0.695202</td>\n",
       "      <td>0.519504</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>1.000656</td>\n",
       "      <td>0.186399</td>\n",
       "      <td>0.674042</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               b         d         e\n",
       "Utah    0.461568  1.144868  0.023796\n",
       "Ohio    0.211013  0.017584  0.775530\n",
       "Texas   0.354119  0.695202  0.519504\n",
       "Oregon  1.000656  0.186399  0.674042"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.abs(frame)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "f = lambda x: x.max() - x.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b    1.462224\n",
       "d    1.331267\n",
       "e    1.449572\n",
       "dtype: float64"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.apply(f,axis='index')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "f = lambda x: pd.Series([x.min(),x.max()],index=['min','max'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>min</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>-0.023796</td>\n",
       "      <td>1.144868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>-0.211013</td>\n",
       "      <td>0.775530</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>0.354119</td>\n",
       "      <td>0.695202</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>-1.000656</td>\n",
       "      <td>-0.186399</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             min       max\n",
       "Utah   -0.023796  1.144868\n",
       "Ohio   -0.211013  0.775530\n",
       "Texas   0.354119  0.695202\n",
       "Oregon -1.000656 -0.186399"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.apply(f,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "format = lambda i: '%.2f' % i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>b</th>\n",
       "      <th>d</th>\n",
       "      <th>e</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Utah</th>\n",
       "      <td>0.46</td>\n",
       "      <td>1.14</td>\n",
       "      <td>-0.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>-0.21</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>0.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Texas</th>\n",
       "      <td>0.35</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oregon</th>\n",
       "      <td>-1.00</td>\n",
       "      <td>-0.19</td>\n",
       "      <td>-0.67</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            b      d      e\n",
       "Utah     0.46   1.14  -0.02\n",
       "Ohio    -0.21  -0.02   0.78\n",
       "Texas    0.35   0.70   0.52\n",
       "Oregon  -1.00  -0.19  -0.67"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.applymap(format)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Utah       0.46\n",
       "Ohio      -0.21\n",
       "Texas      0.35\n",
       "Oregon    -1.00\n",
       "Name: b, dtype: object"
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame['b'].map(format)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series(range(4),index=list('dabc'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    1\n",
       "b    2\n",
       "c    3\n",
       "d    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame = pd.DataFrame(np.arange(8).reshape((2, 4)),\n",
    "index=['three', 'one'],\n",
    "columns=['d', 'a', 'b', 'c'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>three</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>one</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       a  b  c  d\n",
       "three  1  2  3  0\n",
       "one    5  6  7  4"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.sort_index(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>d</th>\n",
       "      <th>c</th>\n",
       "      <th>b</th>\n",
       "      <th>a</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>three</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>one</th>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       d  c  b  a\n",
       "three  0  3  2  1\n",
       "one    4  7  6  5"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.sort_index(axis=1,ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series([4, 7, -3, 2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2   -3\n",
       "3    2\n",
       "0    4\n",
       "1    7\n",
       "dtype: int64"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.sort_values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4   -3.0\n",
       "5    2.0\n",
       "0    4.0\n",
       "2    7.0\n",
       "1    NaN\n",
       "3    NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj = pd.Series([4, np.nan, 7, np.nan, -3, 2])\n",
    "obj.sort_values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame = pd.DataFrame({'b': [4, 7, -3, 2], 'a': [0, 1, 0,\n",
    "1]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>-3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a  b\n",
       "0  0  4\n",
       "1  1  7\n",
       "2  0 -3\n",
       "3  1  2"
      ]
     },
     "execution_count": 146,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>-3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a  b\n",
       "2  0 -3\n",
       "3  1  2\n",
       "0  0  4\n",
       "1  1  7"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.sort_values(by=['b'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>-3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a  b\n",
       "2  0 -3\n",
       "0  0  4\n",
       "3  1  2\n",
       "1  1  7"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.sort_values(by=['a','b'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series([7, -5,-5, 7, 4, 2, 0, 4,4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    8.5\n",
       "1    1.5\n",
       "2    1.5\n",
       "3    8.5\n",
       "4    6.0\n",
       "5    4.0\n",
       "6    3.0\n",
       "7    6.0\n",
       "8    6.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.rank()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(9,)"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5,)"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.unique().shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    8.0\n",
       "1    1.0\n",
       "2    2.0\n",
       "3    9.0\n",
       "4    5.0\n",
       "5    4.0\n",
       "6    3.0\n",
       "7    6.0\n",
       "8    7.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.rank(method='first')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1.0\n",
       "1    8.0\n",
       "2    8.0\n",
       "3    1.0\n",
       "4    3.0\n",
       "5    6.0\n",
       "6    7.0\n",
       "7    3.0\n",
       "8    3.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.rank(ascending=False,method='min')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "frame = pd.DataFrame({'b': [4.3, 7, -3, 2], 'a': [0, 1, 0,\n",
    "1],'c': [-2, 5, 8, -2.5]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>-2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>7.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>-3.0</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a    b    c\n",
       "0  0  4.3 -2.0\n",
       "1  1  7.0  5.0\n",
       "2  0 -3.0  8.0\n",
       "3  1  2.0 -2.5"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     a    b    c\n",
       "0  1.0  3.0  2.0\n",
       "1  2.0  4.0  3.0\n",
       "2  1.0  1.0  4.0\n",
       "3  2.0  2.0  1.0"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.rank(axis=0,method = 'dense')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series(range(5), index=['a', 'a', 'b', 'b', 'c'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 176,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.index.is_unique"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0\n",
       "a    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 178,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.DataFrame(np.random.randn(4, 3), index=['a', 'a',\n",
    "'b', 'b'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 181,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>-0.049437</td>\n",
       "      <td>0.167548</td>\n",
       "      <td>0.475148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1.213460</td>\n",
       "      <td>1.225425</td>\n",
       "      <td>-0.999275</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>0.514109</td>\n",
       "      <td>-0.141164</td>\n",
       "      <td>-1.296492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>1.710104</td>\n",
       "      <td>-0.199271</td>\n",
       "      <td>-0.534090</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2\n",
       "a -0.049437  0.167548  0.475148\n",
       "a  1.213460  1.225425 -0.999275\n",
       "b  0.514109 -0.141164 -1.296492\n",
       "b  1.710104 -0.199271 -0.534090"
      ]
     },
     "execution_count": 181,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>-0.049437</td>\n",
       "      <td>0.167548</td>\n",
       "      <td>0.475148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1.213460</td>\n",
       "      <td>1.225425</td>\n",
       "      <td>-0.999275</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2\n",
       "a -0.049437  0.167548  0.475148\n",
       "a  1.213460  1.225425 -0.999275"
      ]
     },
     "execution_count": 184,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc['a',:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.DataFrame([[1.4, np.nan], [7.1, -4.5],\n",
    "[np.nan, np.nan], [0.75, -1.3]],\n",
    "index=['a', 'b', 'c', 'd'],\n",
    "columns=['one', 'two'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1.40</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>7.10</td>\n",
       "      <td>-4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>0.75</td>\n",
       "      <td>-1.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    one  two\n",
       "a  1.40  NaN\n",
       "b  7.10 -4.5\n",
       "c   NaN  NaN\n",
       "d  0.75 -1.3"
      ]
     },
     "execution_count": 186,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "one    9.25\n",
       "two   -5.80\n",
       "dtype: float64"
      ]
     },
     "execution_count": 187,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    1.40\n",
       "b    2.60\n",
       "c    0.00\n",
       "d   -0.55\n",
       "dtype: float64"
      ]
     },
     "execution_count": 189,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum(axis='columns')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a     NaN\n",
       "b    2.60\n",
       "c     NaN\n",
       "d   -0.55\n",
       "dtype: float64"
      ]
     },
     "execution_count": 191,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum(axis='columns',skipna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    one\n",
       "b    one\n",
       "c    NaN\n",
       "d    one\n",
       "dtype: object"
      ]
     },
     "execution_count": 193,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.idxmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1.40</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>8.50</td>\n",
       "      <td>-4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>9.25</td>\n",
       "      <td>-5.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    one  two\n",
       "a  1.40  NaN\n",
       "b  8.50 -4.5\n",
       "c   NaN  NaN\n",
       "d  9.25 -5.8"
      ]
     },
     "execution_count": 194,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.cumsum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1.4</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>7.1</td>\n",
       "      <td>-4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>7.1</td>\n",
       "      <td>-1.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   one  two\n",
       "a  1.4  NaN\n",
       "b  7.1 -4.5\n",
       "c  NaN  NaN\n",
       "d  7.1 -1.3"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.cummax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1.40</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>1.40</td>\n",
       "      <td>-4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>0.75</td>\n",
       "      <td>-4.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    one  two\n",
       "a  1.40  NaN\n",
       "b  1.40 -4.5\n",
       "c   NaN  NaN\n",
       "d  0.75 -4.5"
      ]
     },
     "execution_count": 197,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.cummin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>3.083333</td>\n",
       "      <td>-2.900000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>3.493685</td>\n",
       "      <td>2.262742</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.750000</td>\n",
       "      <td>-4.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>1.075000</td>\n",
       "      <td>-3.700000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1.400000</td>\n",
       "      <td>-2.900000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>4.250000</td>\n",
       "      <td>-2.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>7.100000</td>\n",
       "      <td>-1.300000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            one       two\n",
       "count  3.000000  2.000000\n",
       "mean   3.083333 -2.900000\n",
       "std    3.493685  2.262742\n",
       "min    0.750000 -4.500000\n",
       "25%    1.075000 -3.700000\n",
       "50%    1.400000 -2.900000\n",
       "75%    4.250000 -2.100000\n",
       "max    7.100000 -1.300000"
      ]
     },
     "execution_count": 198,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series(['a', 'a', 'b', 'c'] * 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count     16\n",
       "unique     3\n",
       "top        a\n",
       "freq       8\n",
       "dtype: object"
      ]
     },
     "execution_count": 200,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "one    1.664846\n",
       "two         NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 201,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.skew()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>5.7</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   one  two\n",
       "a  NaN  NaN\n",
       "b  5.7  NaN\n",
       "c  NaN  NaN\n",
       "d  NaN  NaN"
      ]
     },
     "execution_count": 202,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.diff()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>one</th>\n",
       "      <th>two</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>5.70</td>\n",
       "      <td>-4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>-7.10</td>\n",
       "      <td>4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>0.75</td>\n",
       "      <td>-1.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    one  two\n",
       "a   NaN  NaN\n",
       "b  5.70 -4.5\n",
       "c -7.10  4.5\n",
       "d  0.75 -1.3"
      ]
     },
     "execution_count": 204,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.fillna(0).diff()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas_datareader.data as web\n",
    "import pandas as pd\n",
    "all_data = {ticker: web.get_data_yahoo(ticker)\n",
    "for ticker in ['AAPL', 'IBM', 'MSFT', 'GOOG']}\n",
    "price = pd.DataFrame({ticker: data['Adj Close']\n",
    "for ticker, data in all_data.items()})\n",
    "volume = pd.DataFrame({ticker: data['Volume']\n",
    "for ticker, data in all_data.items()})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'AAPL':                   High         Low        Open       Close       Volume  \\\n",
       " Date                                                                      \n",
       " 2009-12-31   30.478571   30.080000   30.447144   30.104286   88102700.0   \n",
       " 2010-01-04   30.642857   30.340000   30.490000   30.572857  123432400.0   \n",
       " 2010-01-05   30.798571   30.464285   30.657143   30.625713  150476200.0   \n",
       " 2010-01-06   30.747143   30.107143   30.625713   30.138571  138040000.0   \n",
       " 2010-01-07   30.285715   29.864286   30.250000   30.082857  119282800.0   \n",
       " 2010-01-08   30.285715   29.865715   30.042856   30.282858  111902700.0   \n",
       " 2010-01-11   30.428572   29.778572   30.400000   30.015715  115557400.0   \n",
       " 2010-01-12   29.967142   29.488571   29.884285   29.674286  148614900.0   \n",
       " 2010-01-13   30.132856   29.157143   29.695715   30.092857  151473000.0   \n",
       " 2010-01-14   30.065714   29.860001   30.015715   29.918571  108223500.0   \n",
       " 2010-01-15   30.228571   29.410000   30.132856   29.418571  148516900.0   \n",
       " 2010-01-19   30.741428   29.605715   29.761429   30.719999  182501900.0   \n",
       " 2010-01-20   30.792856   29.928572   30.701429   30.247143  153038200.0   \n",
       " 2010-01-21   30.472857   29.601429   30.297142   29.724285  152038600.0   \n",
       " 2010-01-22   29.642857   28.165714   29.540001   28.250000  220441900.0   \n",
       " 2010-01-25   29.242857   28.598572   28.930000   29.010000  266424900.0   \n",
       " 2010-01-26   30.530001   28.940001   29.421429   29.420000  466777500.0   \n",
       " 2010-01-27   30.082857   28.504286   29.549999   29.697144  430642100.0   \n",
       " 2010-01-28   29.357143   28.385714   29.275715   28.469999  293375600.0   \n",
       " 2010-01-29   28.885714   27.178572   28.725714   27.437143  311488100.0   \n",
       " 2010-02-01   28.000000   27.328571   27.481428   27.818571  187469100.0   \n",
       " 2010-02-02   28.045713   27.625713   27.987143   27.980000  174585600.0   \n",
       " 2010-02-03   28.600000   27.774286   27.881428   28.461428  153832000.0   \n",
       " 2010-02-04   28.338572   27.367144   28.104286   27.435715  189413000.0   \n",
       " 2010-02-05   28.000000   27.264286   27.518572   27.922857  212576700.0   \n",
       " 2010-02-08   28.268572   27.714285   27.955715   27.731428  119567700.0   \n",
       " 2010-02-09   28.214285   27.821428   28.059999   28.027143  158221700.0   \n",
       " 2010-02-10   28.085714   27.751429   27.984285   27.874287   92590400.0   \n",
       " 2010-02-11   28.535715   27.722857   27.840000   28.381428  137586400.0   \n",
       " 2010-02-12   28.805714   27.928572   28.301428   28.625713  163867200.0   \n",
       " ...                ...         ...         ...         ...          ...   \n",
       " 2019-01-17  157.660004  153.259995  154.199997  155.860001   29821200.0   \n",
       " 2019-01-18  157.880005  155.979996  157.500000  156.820007   33751000.0   \n",
       " 2019-01-22  156.729996  152.619995  156.410004  153.300003   30394000.0   \n",
       " 2019-01-23  155.139999  151.699997  154.149994  153.919998   23130600.0   \n",
       " 2019-01-24  154.479996  151.740005  154.110001  152.699997   25441500.0   \n",
       " 2019-01-25  158.130005  154.320007  155.479996  157.759995   33535500.0   \n",
       " 2019-01-28  156.330002  153.660004  155.789993  156.300003   26192100.0   \n",
       " 2019-01-29  158.130005  154.110001  156.250000  154.679993   41587200.0   \n",
       " 2019-01-30  166.149994  160.229996  163.250000  165.250000   61109800.0   \n",
       " 2019-01-31  169.000000  164.559998  166.110001  166.440002   40739600.0   \n",
       " 2019-02-01  168.979996  165.929993  166.960007  166.520004   32668100.0   \n",
       " 2019-02-04  171.660004  167.279999  167.410004  171.250000   31495500.0   \n",
       " 2019-02-05  175.080002  172.350006  172.860001  174.179993   36101600.0   \n",
       " 2019-02-06  175.570007  172.850006  174.649994  174.240005   28239600.0   \n",
       " 2019-02-07  173.940002  170.339996  172.399994  170.940002   31741700.0   \n",
       " 2019-02-08  170.660004  168.419998  168.990005  170.410004   23820000.0   \n",
       " 2019-02-11  171.210007  169.250000  171.050003  169.429993   20993400.0   \n",
       " 2019-02-12  171.000000  169.699997  170.100006  170.889999   22283500.0   \n",
       " 2019-02-13  172.479996  169.919998  171.389999  170.179993   22490200.0   \n",
       " 2019-02-14  171.259995  169.380005  169.710007  170.800003   21835700.0   \n",
       " 2019-02-15  171.699997  169.750000  171.250000  170.419998   24626800.0   \n",
       " 2019-02-19  171.440002  169.490005  169.710007  170.929993   18972800.0   \n",
       " 2019-02-20  173.320007  170.990005  171.190002  172.029999   26114400.0   \n",
       " 2019-02-21  172.369995  170.300003  171.800003  171.059998   17249700.0   \n",
       " 2019-02-22  173.000000  171.380005  171.580002  172.970001   18913200.0   \n",
       " 2019-02-25  175.869995  173.949997  174.160004  174.229996   21873400.0   \n",
       " 2019-02-26  175.300003  173.169998  173.710007  174.330002   17070200.0   \n",
       " 2019-02-27  175.000000  172.729996  173.210007  174.869995   27835400.0   \n",
       " 2019-02-28  174.910004  172.919998  174.320007  173.149994   28215400.0   \n",
       " 2019-03-01  175.149994  172.889999  174.279999  174.970001   25873500.0   \n",
       " \n",
       "              Adj Close  \n",
       " Date                    \n",
       " 2009-12-31   20.073631  \n",
       " 2010-01-04   20.386072  \n",
       " 2010-01-05   20.421322  \n",
       " 2010-01-06   20.096491  \n",
       " 2010-01-07   20.059338  \n",
       " 2010-01-08   20.192701  \n",
       " 2010-01-11   20.014568  \n",
       " 2010-01-12   19.786903  \n",
       " 2010-01-13   20.066006  \n",
       " 2010-01-14   19.949797  \n",
       " 2010-01-15   19.616390  \n",
       " 2010-01-19   20.484186  \n",
       " 2010-01-20   20.168890  \n",
       " 2010-01-21   19.820242  \n",
       " 2010-01-22   18.837185  \n",
       " 2010-01-25   19.343958  \n",
       " 2010-01-26   19.617346  \n",
       " 2010-01-27   19.802147  \n",
       " 2010-01-28   18.983883  \n",
       " 2010-01-29   18.295170  \n",
       " 2010-02-01   18.549507  \n",
       " 2010-02-02   18.657150  \n",
       " 2010-02-03   18.978167  \n",
       " 2010-02-04   18.294220  \n",
       " 2010-02-05   18.619045  \n",
       " 2010-02-08   18.491404  \n",
       " 2010-02-09   18.688580  \n",
       " 2010-02-10   18.586657  \n",
       " 2010-02-11   18.924822  \n",
       " 2010-02-12   19.087709  \n",
       " ...                ...  \n",
       " 2019-01-17  155.194397  \n",
       " 2019-01-18  156.150314  \n",
       " 2019-01-22  152.645340  \n",
       " 2019-01-23  153.262680  \n",
       " 2019-01-24  152.047897  \n",
       " 2019-01-25  157.086288  \n",
       " 2019-01-28  155.632523  \n",
       " 2019-01-29  154.019440  \n",
       " 2019-01-30  164.544296  \n",
       " 2019-01-31  165.729218  \n",
       " 2019-02-01  165.808884  \n",
       " 2019-02-04  170.518677  \n",
       " 2019-02-05  173.436157  \n",
       " 2019-02-06  173.495911  \n",
       " 2019-02-07  170.210007  \n",
       " 2019-02-08  170.410004  \n",
       " 2019-02-11  169.429993  \n",
       " 2019-02-12  170.889999  \n",
       " 2019-02-13  170.179993  \n",
       " 2019-02-14  170.800003  \n",
       " 2019-02-15  170.419998  \n",
       " 2019-02-19  170.929993  \n",
       " 2019-02-20  172.029999  \n",
       " 2019-02-21  171.059998  \n",
       " 2019-02-22  172.970001  \n",
       " 2019-02-25  174.229996  \n",
       " 2019-02-26  174.330002  \n",
       " 2019-02-27  174.869995  \n",
       " 2019-02-28  173.149994  \n",
       " 2019-03-01  174.970001  \n",
       " \n",
       " [2306 rows x 6 columns],\n",
       " 'GOOG':                    High          Low         Open        Close      Volume  \\\n",
       " Date                                                                         \n",
       " 2009-12-31   310.679321   307.986847   310.356445   307.986847   2455400.0   \n",
       " 2010-01-04   312.721039   310.103088   311.449310   311.349976   3937800.0   \n",
       " 2010-01-05   311.891449   308.761810   311.563568   309.978882   6048500.0   \n",
       " 2010-01-06   310.907837   301.220856   310.907837   302.164703   8009000.0   \n",
       " 2010-01-07   303.029083   294.410156   302.731018   295.130463  12912000.0   \n",
       " 2010-01-08   299.675903   292.651581   294.087250   299.064880   9509900.0   \n",
       " 2010-01-11   300.276978   295.100647   300.276978   298.612823  14519600.0   \n",
       " 2010-01-12   297.147339   292.100159   296.893982   293.332153   9769600.0   \n",
       " 2010-01-13   292.288940   285.095734   286.382355   291.648102  13077600.0   \n",
       " 2010-01-14   295.180145   289.521942   290.063416   293.019196   8535300.0   \n",
       " 2010-01-15   294.862213   287.152344   294.752930   288.126007  10939600.0   \n",
       " 2010-01-19   293.302338   286.283020   288.722137   291.911407   8689500.0   \n",
       " 2010-01-20   291.096710   285.786224   291.096710   288.329681   6543600.0   \n",
       " 2010-01-21   291.513977   284.276062   289.834900   289.606384  12697400.0   \n",
       " 2010-01-22   283.456390   265.701874   280.426086   273.227905  13689200.0   \n",
       " 2010-01-25   273.163330   266.024780   271.528961   268.255249   8897200.0   \n",
       " 2010-01-26   273.024231   266.412231   267.246826   269.457428   8767600.0   \n",
       " 2010-01-27   272.055542   265.925415   268.886169   269.298462   7980200.0   \n",
       " 2010-01-28   271.732635   263.585632   270.485748   265.418701   6500100.0   \n",
       " 2010-01-29   268.747070   261.106750   267.505127   263.257751   8334700.0   \n",
       " 2010-02-01   266.173798   263.436584   265.572693   264.787811   4530800.0   \n",
       " 2010-02-02   265.751556   262.100281   265.751556   263.843964   8245600.0   \n",
       " 2010-02-03   269.298462   262.408295   262.626862   268.662598   6037000.0   \n",
       " 2010-02-04   267.261719   261.081909   266.764954   261.687958   6799200.0   \n",
       " 2010-02-05   265.026245   259.541931   262.492737   263.928406   6353000.0   \n",
       " 2010-02-08   269.248810   264.047638   264.529480   265.011353   5423500.0   \n",
       " 2010-02-09   269.015320   265.806183   268.026733   266.486755   5675700.0   \n",
       " 2010-02-10   267.157410   262.140045   265.309418   265.498199   5383700.0   \n",
       " 2010-02-11   268.498688   263.039185   264.936829   266.466888   4851300.0   \n",
       " 2010-02-12   266.839478   263.535950   264.762970   264.837494   4589000.0   \n",
       " ...                 ...          ...          ...          ...         ...   \n",
       " 2019-01-17  1091.800049  1073.500000  1079.469971  1089.900024   1242700.0   \n",
       " 2019-01-18  1108.352051  1090.900024  1100.000000  1098.260010   1955600.0   \n",
       " 2019-01-22  1091.510010  1063.469971  1088.000000  1070.520020   1613500.0   \n",
       " 2019-01-23  1084.930054  1059.750000  1077.349976  1075.569946    967000.0   \n",
       " 2019-01-24  1079.474976  1060.699951  1076.479980  1073.900024   1361300.0   \n",
       " 2019-01-25  1094.000000  1081.819946  1085.000000  1090.989990   1119100.0   \n",
       " 2019-01-28  1083.000000  1063.800049  1080.109985  1070.079956   1284300.0   \n",
       " 2019-01-29  1075.150024  1055.864990  1072.680054  1060.619995   1021800.0   \n",
       " 2019-01-30  1091.000000  1066.849976  1068.430054  1089.060059   1279800.0   \n",
       " 2019-01-31  1117.329956  1095.410034  1103.000000  1116.369995   1538300.0   \n",
       " 2019-02-01  1125.000000  1104.890015  1112.400024  1110.750000   1462200.0   \n",
       " 2019-02-04  1132.800049  1109.020020  1112.660034  1132.800049   2576500.0   \n",
       " 2019-02-05  1146.849976  1117.248047  1124.839966  1145.989990   3552200.0   \n",
       " 2019-02-06  1147.000000  1112.770020  1139.569946  1115.229980   2105600.0   \n",
       " 2019-02-07  1104.839966  1086.000000  1104.160034  1098.709961   2044800.0   \n",
       " 2019-02-08  1098.910034  1086.550049  1087.000000  1095.060059   1075800.0   \n",
       " 2019-02-11  1105.944946  1092.859985  1096.949951  1095.010010   1065200.0   \n",
       " 2019-02-12  1125.295044  1105.849976  1106.800049  1121.369995   1609100.0   \n",
       " 2019-02-13  1134.729980  1118.500000  1124.989990  1120.160034   1049800.0   \n",
       " 2019-02-14  1128.229980  1110.444946  1118.050049  1121.670044    947600.0   \n",
       " 2019-02-15  1131.670044  1110.650024  1130.079956  1113.650024   1449800.0   \n",
       " 2019-02-19  1121.890015  1110.000000  1110.000000  1118.560059   1046400.0   \n",
       " 2019-02-20  1123.410034  1105.280029  1119.989990  1113.800049   1087800.0   \n",
       " 2019-02-21  1111.939941  1092.520020  1110.839966  1096.969971   1415100.0   \n",
       " 2019-02-22  1111.239990  1095.599976  1100.900024  1110.369995   1049500.0   \n",
       " 2019-02-25  1118.540039  1107.270020  1116.000000  1109.400024   1413100.0   \n",
       " 2019-02-26  1119.510010  1099.920044  1105.750000  1115.130005   1471300.0   \n",
       " 2019-02-27  1117.979980  1101.000000  1106.949951  1116.050049    968400.0   \n",
       " 2019-02-28  1127.650024  1111.010010  1111.300049  1119.920044   1542500.0   \n",
       " 2019-03-01  1142.969971  1124.750000  1124.900024  1140.989990   1449800.0   \n",
       " \n",
       "               Adj Close  \n",
       " Date                     \n",
       " 2009-12-31   307.986847  \n",
       " 2010-01-04   311.349976  \n",
       " 2010-01-05   309.978882  \n",
       " 2010-01-06   302.164703  \n",
       " 2010-01-07   295.130463  \n",
       " 2010-01-08   299.064880  \n",
       " 2010-01-11   298.612823  \n",
       " 2010-01-12   293.332153  \n",
       " 2010-01-13   291.648102  \n",
       " 2010-01-14   293.019196  \n",
       " 2010-01-15   288.126007  \n",
       " 2010-01-19   291.911407  \n",
       " 2010-01-20   288.329681  \n",
       " 2010-01-21   289.606384  \n",
       " 2010-01-22   273.227905  \n",
       " 2010-01-25   268.255249  \n",
       " 2010-01-26   269.457428  \n",
       " 2010-01-27   269.298462  \n",
       " 2010-01-28   265.418701  \n",
       " 2010-01-29   263.257751  \n",
       " 2010-02-01   264.787811  \n",
       " 2010-02-02   263.843964  \n",
       " 2010-02-03   268.662598  \n",
       " 2010-02-04   261.687958  \n",
       " 2010-02-05   263.928406  \n",
       " 2010-02-08   265.011353  \n",
       " 2010-02-09   266.486755  \n",
       " 2010-02-10   265.498199  \n",
       " 2010-02-11   266.466888  \n",
       " 2010-02-12   264.837494  \n",
       " ...                 ...  \n",
       " 2019-01-17  1089.900024  \n",
       " 2019-01-18  1098.260010  \n",
       " 2019-01-22  1070.520020  \n",
       " 2019-01-23  1075.569946  \n",
       " 2019-01-24  1073.900024  \n",
       " 2019-01-25  1090.989990  \n",
       " 2019-01-28  1070.079956  \n",
       " 2019-01-29  1060.619995  \n",
       " 2019-01-30  1089.060059  \n",
       " 2019-01-31  1116.369995  \n",
       " 2019-02-01  1110.750000  \n",
       " 2019-02-04  1132.800049  \n",
       " 2019-02-05  1145.989990  \n",
       " 2019-02-06  1115.229980  \n",
       " 2019-02-07  1098.709961  \n",
       " 2019-02-08  1095.060059  \n",
       " 2019-02-11  1095.010010  \n",
       " 2019-02-12  1121.369995  \n",
       " 2019-02-13  1120.160034  \n",
       " 2019-02-14  1121.670044  \n",
       " 2019-02-15  1113.650024  \n",
       " 2019-02-19  1118.560059  \n",
       " 2019-02-20  1113.800049  \n",
       " 2019-02-21  1096.969971  \n",
       " 2019-02-22  1110.369995  \n",
       " 2019-02-25  1109.400024  \n",
       " 2019-02-26  1115.130005  \n",
       " 2019-02-27  1116.050049  \n",
       " 2019-02-28  1119.920044  \n",
       " 2019-03-01  1140.989990  \n",
       " \n",
       " [2306 rows x 6 columns],\n",
       " 'IBM':                   High         Low        Open       Close      Volume  \\\n",
       " Date                                                                     \n",
       " 2009-12-31  132.850006  130.750000  132.410004  130.899994   4223400.0   \n",
       " 2010-01-04  132.970001  130.850006  131.179993  132.449997   6155300.0   \n",
       " 2010-01-05  131.850006  130.100006  131.679993  130.850006   6841400.0   \n",
       " 2010-01-06  131.490005  129.809998  130.679993  130.000000   5605300.0   \n",
       " 2010-01-07  130.250000  128.910004  129.869995  129.550003   5840600.0   \n",
       " 2010-01-08  130.919998  129.050003  129.070007  130.850006   4197200.0   \n",
       " 2010-01-11  131.059998  128.669998  131.059998  129.479996   5730400.0   \n",
       " 2010-01-12  131.330002  129.000000  129.029999  130.509995   8081500.0   \n",
       " 2010-01-13  131.119995  129.160004  130.389999  130.229996   6455400.0   \n",
       " 2010-01-14  132.710007  129.910004  130.550003  132.309998   7111800.0   \n",
       " 2010-01-15  132.889999  131.089996  132.029999  131.779999   8494400.0   \n",
       " 2010-01-19  134.250000  131.559998  131.630005  134.139999  13916200.0   \n",
       " 2010-01-20  131.149994  128.949997  130.460007  130.250000  15197500.0   \n",
       " 2010-01-21  130.690002  128.059998  130.470001  129.000000   9608600.0   \n",
       " 2010-01-22  128.889999  125.370003  128.669998  125.500000  10088600.0   \n",
       " 2010-01-25  126.889999  125.709999  126.330002  126.120003   5738500.0   \n",
       " 2010-01-26  127.750000  125.410004  125.919998  125.750000   7135300.0   \n",
       " 2010-01-27  126.959999  125.040001  125.820000  126.330002   8719200.0   \n",
       " 2010-01-28  127.040001  123.050003  127.029999  123.750000   9622200.0   \n",
       " 2010-01-29  125.000000  121.900002  124.320000  122.389999  11571200.0   \n",
       " 2010-02-01  124.949997  122.779999  123.230003  124.669998   7242900.0   \n",
       " 2010-02-02  125.809998  123.949997  124.790001  125.529999   5899900.0   \n",
       " 2010-02-03  126.070000  125.070000  125.160004  125.660004   4177100.0   \n",
       " 2010-02-04  125.440002  122.900002  125.190002  123.000000   9126900.0   \n",
       " 2010-02-05  123.720001  121.830002  123.040001  123.519997   8617000.0   \n",
       " 2010-02-08  123.220001  121.739998  123.150002  121.879997   5718500.0   \n",
       " 2010-02-09  124.199997  122.459999  122.650002  123.209999   6044500.0   \n",
       " 2010-02-10  123.650002  122.209999  122.940002  122.809998   5219100.0   \n",
       " 2010-02-11  124.199997  122.059998  122.580002  123.730003   5089000.0   \n",
       " 2010-02-12  124.050003  121.610001  123.010002  124.000000   8017700.0   \n",
       " ...                ...         ...         ...         ...         ...   \n",
       " 2019-01-17  122.410004  120.550003  120.559998  122.190002   5029900.0   \n",
       " 2019-01-18  124.720001  122.709999  123.269997  123.820000   6008500.0   \n",
       " 2019-01-22  123.800003  121.540001  123.300003  122.519997  10052400.0   \n",
       " 2019-01-23  135.000000  130.309998  131.369995  132.889999  22063700.0   \n",
       " 2019-01-24  133.210007  131.429993  132.630005  132.529999   6322900.0   \n",
       " 2019-01-25  134.440002  132.429993  132.869995  133.970001   5707400.0   \n",
       " 2019-01-28  134.809998  132.580002  133.100006  134.270004   5357700.0   \n",
       " 2019-01-29  135.410004  133.600006  134.289993  134.330002   5037100.0   \n",
       " 2019-01-30  135.029999  133.250000  134.000000  134.380005   4500900.0   \n",
       " 2019-01-31  134.720001  133.740005  134.449997  134.419998   4884000.0   \n",
       " 2019-02-01  135.199997  133.350006  134.970001  134.100006   3806000.0   \n",
       " 2019-02-04  135.199997  132.990005  134.020004  135.190002   3966600.0   \n",
       " 2019-02-05  135.820007  134.919998  135.279999  135.550003   5398900.0   \n",
       " 2019-02-06  136.649994  135.169998  135.220001  136.320007   4879700.0   \n",
       " 2019-02-07  134.470001  132.119995  133.550003  133.190002   4379400.0   \n",
       " 2019-02-08  133.710007  132.190002  132.339996  133.710007   3249800.0   \n",
       " 2019-02-11  135.149994  133.910004  134.289993  133.990005   3095100.0   \n",
       " 2019-02-12  136.199997  134.860001  135.149994  136.050003   3317200.0   \n",
       " 2019-02-13  137.919998  136.410004  136.919998  137.520004   4253000.0   \n",
       " 2019-02-14  137.600006  136.210007  137.169998  136.479996   2789400.0   \n",
       " 2019-02-15  138.190002  137.389999  137.580002  138.029999   3844100.0   \n",
       " 2019-02-19  138.699997  137.360001  137.809998  138.699997   3385700.0   \n",
       " 2019-02-20  139.240005  137.220001  138.759995  138.000000   3802000.0   \n",
       " 2019-02-21  138.350006  137.350006  137.820007  137.839996   2937300.0   \n",
       " 2019-02-22  139.380005  138.429993  138.729996  139.250000   3113700.0   \n",
       " 2019-02-25  140.470001  139.320007  140.000000  139.460007   3194200.0   \n",
       " 2019-02-26  140.490005  139.470001  139.669998  139.720001   3060400.0   \n",
       " 2019-02-27  139.570007  138.399994  139.250000  139.169998   2530900.0   \n",
       " 2019-02-28  139.059998  137.720001  138.770004  138.130005   3457800.0   \n",
       " 2019-03-01  140.039993  138.639999  139.309998  139.199997   2979600.0   \n",
       " \n",
       "              Adj Close  \n",
       " Date                    \n",
       " 2009-12-31   99.303009  \n",
       " 2010-01-04  100.478867  \n",
       " 2010-01-05   99.265091  \n",
       " 2010-01-06   98.620255  \n",
       " 2010-01-07   98.278870  \n",
       " 2010-01-08   99.265091  \n",
       " 2010-01-11   98.225777  \n",
       " 2010-01-12   99.007156  \n",
       " 2010-01-13   98.794746  \n",
       " 2010-01-14  100.372673  \n",
       " 2010-01-15   99.970589  \n",
       " 2010-01-19  101.760918  \n",
       " 2010-01-20   98.809929  \n",
       " 2010-01-21   97.861649  \n",
       " 2010-01-22   95.206505  \n",
       " 2010-01-25   95.676834  \n",
       " 2010-01-26   95.396156  \n",
       " 2010-01-27   95.836143  \n",
       " 2010-01-28   93.878906  \n",
       " 2010-01-29   92.847176  \n",
       " 2010-02-01   94.576828  \n",
       " 2010-02-02   95.229240  \n",
       " 2010-02-03   95.327866  \n",
       " 2010-02-04   93.309929  \n",
       " 2010-02-05   93.704422  \n",
       " 2010-02-08   92.873825  \n",
       " 2010-02-09   93.887291  \n",
       " 2010-02-10   93.582497  \n",
       " 2010-02-11   94.283569  \n",
       " 2010-02-12   94.489265  \n",
       " ...                ...  \n",
       " 2019-01-17  120.782738  \n",
       " 2019-01-18  122.393959  \n",
       " 2019-01-22  121.108925  \n",
       " 2019-01-23  131.359497  \n",
       " 2019-01-24  131.003647  \n",
       " 2019-01-25  132.427063  \n",
       " 2019-01-28  132.723618  \n",
       " 2019-01-29  132.782913  \n",
       " 2019-01-30  132.832336  \n",
       " 2019-01-31  132.871872  \n",
       " 2019-02-01  132.555573  \n",
       " 2019-02-04  133.633011  \n",
       " 2019-02-05  133.988861  \n",
       " 2019-02-06  134.750000  \n",
       " 2019-02-07  133.190002  \n",
       " 2019-02-08  133.710007  \n",
       " 2019-02-11  133.990005  \n",
       " 2019-02-12  136.050003  \n",
       " 2019-02-13  137.520004  \n",
       " 2019-02-14  136.479996  \n",
       " 2019-02-15  138.029999  \n",
       " 2019-02-19  138.699997  \n",
       " 2019-02-20  138.000000  \n",
       " 2019-02-21  137.839996  \n",
       " 2019-02-22  139.250000  \n",
       " 2019-02-25  139.460007  \n",
       " 2019-02-26  139.720001  \n",
       " 2019-02-27  139.169998  \n",
       " 2019-02-28  138.130005  \n",
       " 2019-03-01  139.199997  \n",
       " \n",
       " [2306 rows x 6 columns],\n",
       " 'MSFT':                   High         Low        Open       Close       Volume  \\\n",
       " Date                                                                      \n",
       " 2009-12-31   30.990000   30.480000   30.980000   30.480000   31929700.0   \n",
       " 2010-01-04   31.100000   30.590000   30.620001   30.950001   38409100.0   \n",
       " 2010-01-05   31.100000   30.639999   30.850000   30.959999   49749600.0   \n",
       " 2010-01-06   31.080000   30.520000   30.879999   30.770000   58182400.0   \n",
       " 2010-01-07   30.700001   30.190001   30.629999   30.450001   50559700.0   \n",
       " 2010-01-08   30.879999   30.240000   30.280001   30.660000   51197400.0   \n",
       " 2010-01-11   30.760000   30.120001   30.709999   30.270000   68754700.0   \n",
       " 2010-01-12   30.400000   29.910000   30.150000   30.070000   65912100.0   \n",
       " 2010-01-13   30.520000   30.010000   30.260000   30.350000   51863500.0   \n",
       " 2010-01-14   31.100000   30.260000   30.309999   30.959999   63228100.0   \n",
       " 2010-01-15   31.240000   30.709999   31.080000   30.860001   79913200.0   \n",
       " 2010-01-19   31.240000   30.680000   30.750000   31.100000   46575700.0   \n",
       " 2010-01-20   30.940001   30.309999   30.809999   30.590000   54849500.0   \n",
       " 2010-01-21   30.719999   30.000000   30.610001   30.010000   73086700.0   \n",
       " 2010-01-22   30.200001   28.840000   30.000000   28.959999  102004600.0   \n",
       " 2010-01-25   29.660000   29.100000   29.240000   29.320000   63373000.0   \n",
       " 2010-01-26   29.850000   29.090000   29.200001   29.500000   66639900.0   \n",
       " 2010-01-27   29.820000   29.020000   29.350000   29.670000   63949500.0   \n",
       " 2010-01-28   29.870001   28.889999   29.840000   29.160000  117513700.0   \n",
       " 2010-01-29   29.920000   27.660000   29.900000   28.180000  193888500.0   \n",
       " 2010-02-01   28.480000   27.920000   28.389999   28.410000   85931100.0   \n",
       " 2010-02-02   28.500000   28.139999   28.370001   28.459999   54413700.0   \n",
       " 2010-02-03   28.790001   28.120001   28.260000   28.629999   61397900.0   \n",
       " 2010-02-04   28.500000   27.809999   28.379999   27.840000   77850000.0   \n",
       " 2010-02-05   28.280001   27.570000   28.000000   28.020000   80960100.0   \n",
       " 2010-02-08   28.080000   27.570000   28.010000   27.719999   52820600.0   \n",
       " 2010-02-09   28.340000   27.750000   27.969999   28.010000   59195800.0   \n",
       " 2010-02-10   28.240000   27.840000   28.030001   27.990000   48591300.0   \n",
       " 2010-02-11   28.400000   27.700001   27.930000   28.120001   65993700.0   \n",
       " 2010-02-12   28.059999   27.580000   27.809999   27.930000   81117200.0   \n",
       " ...                ...         ...         ...         ...          ...   \n",
       " 2019-01-17  106.629997  104.760002  105.000000  106.120003   28393000.0   \n",
       " 2019-01-18  107.900002  105.910004  107.459999  107.709999   37427600.0   \n",
       " 2019-01-22  107.099998  104.860001  106.750000  105.680000   32371300.0   \n",
       " 2019-01-23  107.040001  105.339996  106.120003  106.709999   25874300.0   \n",
       " 2019-01-24  107.000000  105.339996  106.860001  106.199997   23164800.0   \n",
       " 2019-01-25  107.879997  106.199997  107.239998  107.169998   31225600.0   \n",
       " 2019-01-28  106.480003  104.660004  106.260002  105.080002   29476700.0   \n",
       " 2019-01-29  104.970001  102.169998  104.879997  102.940002   31490500.0   \n",
       " 2019-01-30  106.379997  104.330002  104.620003  106.379997   49471900.0   \n",
       " 2019-01-31  105.220001  103.180000  103.800003  104.430000   55636400.0   \n",
       " 2019-02-01  104.099998  102.349998  103.779999  102.779999   35535700.0   \n",
       " 2019-02-04  105.800003  102.769997  102.870003  105.739998   31315100.0   \n",
       " 2019-02-05  107.269997  105.959999  106.059998  107.220001   27325400.0   \n",
       " 2019-02-06  107.000000  105.529999  107.000000  106.029999   20609800.0   \n",
       " 2019-02-07  105.589996  104.290001  105.190002  105.269997   29760700.0   \n",
       " 2019-02-08  105.779999  104.260002  104.389999  105.669998   21461100.0   \n",
       " 2019-02-11  106.580002  104.970001  106.199997  105.250000   18914100.0   \n",
       " 2019-02-12  107.139999  105.480003  106.139999  106.889999   25056600.0   \n",
       " 2019-02-13  107.779999  106.709999  107.500000  106.809998   18394900.0   \n",
       " 2019-02-14  107.290001  105.660004  106.309998  106.900002   21784700.0   \n",
       " 2019-02-15  108.300003  107.360001  107.910004  108.220001   26606900.0   \n",
       " 2019-02-19  108.660004  107.779999  107.790001  108.169998   18038500.0   \n",
       " 2019-02-20  107.940002  106.290001  107.860001  107.150002   21607700.0   \n",
       " 2019-02-21  109.480003  106.870003  106.900002  109.410004   29063200.0   \n",
       " 2019-02-22  111.199997  109.820000  110.050003  110.970001   27763200.0   \n",
       " 2019-02-25  112.180000  111.260002  111.760002  111.589996   23750600.0   \n",
       " 2019-02-26  113.239998  111.169998  111.260002  112.360001   21536700.0   \n",
       " 2019-02-27  112.360001  110.879997  111.690002  112.169998   21487100.0   \n",
       " 2019-02-28  112.879997  111.730003  112.040001  112.029999   29083900.0   \n",
       " 2019-03-01  113.019997  111.669998  112.889999  112.529999   20827800.0   \n",
       " \n",
       "              Adj Close  \n",
       " Date                    \n",
       " 2009-12-31   24.241983  \n",
       " 2010-01-04   24.615801  \n",
       " 2010-01-05   24.623755  \n",
       " 2010-01-06   24.472631  \n",
       " 2010-01-07   24.218124  \n",
       " 2010-01-08   24.385145  \n",
       " 2010-01-11   24.074966  \n",
       " 2010-01-12   23.915895  \n",
       " 2010-01-13   24.138592  \n",
       " 2010-01-14   24.623755  \n",
       " 2010-01-15   24.544212  \n",
       " 2010-01-19   24.735104  \n",
       " 2010-01-20   24.329473  \n",
       " 2010-01-21   23.868181  \n",
       " 2010-01-22   23.033073  \n",
       " 2010-01-25   23.319397  \n",
       " 2010-01-26   23.462553  \n",
       " 2010-01-27   23.597769  \n",
       " 2010-01-28   23.192135  \n",
       " 2010-01-29   22.412704  \n",
       " 2010-02-01   22.595629  \n",
       " 2010-02-02   22.635405  \n",
       " 2010-02-03   22.770605  \n",
       " 2010-02-04   22.142290  \n",
       " 2010-02-05   22.285454  \n",
       " 2010-02-08   22.046848  \n",
       " 2010-02-09   22.277498  \n",
       " 2010-02-10   22.261591  \n",
       " 2010-02-11   22.364988  \n",
       " 2010-02-12   22.213871  \n",
       " ...                ...  \n",
       " 2019-01-17  105.668724  \n",
       " 2019-01-18  107.251953  \n",
       " 2019-01-22  105.230591  \n",
       " 2019-01-23  106.256210  \n",
       " 2019-01-24  105.748375  \n",
       " 2019-01-25  106.714249  \n",
       " 2019-01-28  104.633141  \n",
       " 2019-01-29  102.502243  \n",
       " 2019-01-30  105.927612  \n",
       " 2019-01-31  103.985909  \n",
       " 2019-02-01  102.342918  \n",
       " 2019-02-04  105.290337  \n",
       " 2019-02-05  106.764046  \n",
       " 2019-02-06  105.579102  \n",
       " 2019-02-07  104.822327  \n",
       " 2019-02-08  105.220634  \n",
       " 2019-02-11  104.802422  \n",
       " 2019-02-12  106.435448  \n",
       " 2019-02-13  106.355782  \n",
       " 2019-02-14  106.445404  \n",
       " 2019-02-15  107.759789  \n",
       " 2019-02-19  107.709999  \n",
       " 2019-02-20  107.150002  \n",
       " 2019-02-21  109.410004  \n",
       " 2019-02-22  110.970001  \n",
       " 2019-02-25  111.589996  \n",
       " 2019-02-26  112.360001  \n",
       " 2019-02-27  112.169998  \n",
       " 2019-02-28  112.029999  \n",
       " 2019-03-01  112.529999  \n",
       " \n",
       " [2306 rows x 6 columns]}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>GOOG</th>\n",
       "      <th>IBM</th>\n",
       "      <th>MSFT</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2009-12-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-04</th>\n",
       "      <td>0.015565</td>\n",
       "      <td>0.010920</td>\n",
       "      <td>0.011841</td>\n",
       "      <td>0.015420</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-05</th>\n",
       "      <td>0.001729</td>\n",
       "      <td>-0.004404</td>\n",
       "      <td>-0.012080</td>\n",
       "      <td>0.000323</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-06</th>\n",
       "      <td>-0.015906</td>\n",
       "      <td>-0.025209</td>\n",
       "      <td>-0.006496</td>\n",
       "      <td>-0.006137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-07</th>\n",
       "      <td>-0.001849</td>\n",
       "      <td>-0.023279</td>\n",
       "      <td>-0.003462</td>\n",
       "      <td>-0.010400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-08</th>\n",
       "      <td>0.006648</td>\n",
       "      <td>0.013331</td>\n",
       "      <td>0.010035</td>\n",
       "      <td>0.006897</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-11</th>\n",
       "      <td>-0.008822</td>\n",
       "      <td>-0.001512</td>\n",
       "      <td>-0.010470</td>\n",
       "      <td>-0.012720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-12</th>\n",
       "      <td>-0.011375</td>\n",
       "      <td>-0.017684</td>\n",
       "      <td>0.007955</td>\n",
       "      <td>-0.006607</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-13</th>\n",
       "      <td>0.014105</td>\n",
       "      <td>-0.005741</td>\n",
       "      <td>-0.002145</td>\n",
       "      <td>0.009312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-14</th>\n",
       "      <td>-0.005791</td>\n",
       "      <td>0.004701</td>\n",
       "      <td>0.015972</td>\n",
       "      <td>0.020099</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-15</th>\n",
       "      <td>-0.016712</td>\n",
       "      <td>-0.016699</td>\n",
       "      <td>-0.004006</td>\n",
       "      <td>-0.003230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-19</th>\n",
       "      <td>0.044238</td>\n",
       "      <td>0.013138</td>\n",
       "      <td>0.017909</td>\n",
       "      <td>0.007777</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-20</th>\n",
       "      <td>-0.015392</td>\n",
       "      <td>-0.012270</td>\n",
       "      <td>-0.028999</td>\n",
       "      <td>-0.016399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-21</th>\n",
       "      <td>-0.017286</td>\n",
       "      <td>0.004428</td>\n",
       "      <td>-0.009597</td>\n",
       "      <td>-0.018960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-22</th>\n",
       "      <td>-0.049599</td>\n",
       "      <td>-0.056554</td>\n",
       "      <td>-0.027132</td>\n",
       "      <td>-0.034988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-25</th>\n",
       "      <td>0.026903</td>\n",
       "      <td>-0.018200</td>\n",
       "      <td>0.004940</td>\n",
       "      <td>0.012431</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-26</th>\n",
       "      <td>0.014133</td>\n",
       "      <td>0.004481</td>\n",
       "      <td>-0.002934</td>\n",
       "      <td>0.006139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-27</th>\n",
       "      <td>0.009420</td>\n",
       "      <td>-0.000590</td>\n",
       "      <td>0.004612</td>\n",
       "      <td>0.005763</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-28</th>\n",
       "      <td>-0.041322</td>\n",
       "      <td>-0.014407</td>\n",
       "      <td>-0.020423</td>\n",
       "      <td>-0.017190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-29</th>\n",
       "      <td>-0.036279</td>\n",
       "      <td>-0.008142</td>\n",
       "      <td>-0.010990</td>\n",
       "      <td>-0.033608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-01</th>\n",
       "      <td>0.013902</td>\n",
       "      <td>0.005812</td>\n",
       "      <td>0.018629</td>\n",
       "      <td>0.008162</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-02</th>\n",
       "      <td>0.005803</td>\n",
       "      <td>-0.003565</td>\n",
       "      <td>0.006898</td>\n",
       "      <td>0.001760</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-03</th>\n",
       "      <td>0.017206</td>\n",
       "      <td>0.018263</td>\n",
       "      <td>0.001036</td>\n",
       "      <td>0.005973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-04</th>\n",
       "      <td>-0.036039</td>\n",
       "      <td>-0.025961</td>\n",
       "      <td>-0.021168</td>\n",
       "      <td>-0.027593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-05</th>\n",
       "      <td>0.017756</td>\n",
       "      <td>0.008562</td>\n",
       "      <td>0.004228</td>\n",
       "      <td>0.006466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-08</th>\n",
       "      <td>-0.006855</td>\n",
       "      <td>0.004103</td>\n",
       "      <td>-0.008864</td>\n",
       "      <td>-0.010707</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-09</th>\n",
       "      <td>0.010663</td>\n",
       "      <td>0.005567</td>\n",
       "      <td>0.010912</td>\n",
       "      <td>0.010462</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-10</th>\n",
       "      <td>-0.005454</td>\n",
       "      <td>-0.003710</td>\n",
       "      <td>-0.003246</td>\n",
       "      <td>-0.000714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-11</th>\n",
       "      <td>0.018194</td>\n",
       "      <td>0.003649</td>\n",
       "      <td>0.007491</td>\n",
       "      <td>0.004645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-12</th>\n",
       "      <td>0.008607</td>\n",
       "      <td>-0.006115</td>\n",
       "      <td>0.002182</td>\n",
       "      <td>-0.006757</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-17</th>\n",
       "      <td>0.005938</td>\n",
       "      <td>0.008261</td>\n",
       "      <td>0.004687</td>\n",
       "      <td>0.007022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-18</th>\n",
       "      <td>0.006159</td>\n",
       "      <td>0.007670</td>\n",
       "      <td>0.013340</td>\n",
       "      <td>0.014983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-22</th>\n",
       "      <td>-0.022446</td>\n",
       "      <td>-0.025258</td>\n",
       "      <td>-0.010499</td>\n",
       "      <td>-0.018847</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-23</th>\n",
       "      <td>0.004044</td>\n",
       "      <td>0.004717</td>\n",
       "      <td>0.084639</td>\n",
       "      <td>0.009746</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-24</th>\n",
       "      <td>-0.007926</td>\n",
       "      <td>-0.001553</td>\n",
       "      <td>-0.002709</td>\n",
       "      <td>-0.004779</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-25</th>\n",
       "      <td>0.033137</td>\n",
       "      <td>0.015914</td>\n",
       "      <td>0.010865</td>\n",
       "      <td>0.009134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-28</th>\n",
       "      <td>-0.009255</td>\n",
       "      <td>-0.019166</td>\n",
       "      <td>0.002239</td>\n",
       "      <td>-0.019502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-29</th>\n",
       "      <td>-0.010365</td>\n",
       "      <td>-0.008840</td>\n",
       "      <td>0.000447</td>\n",
       "      <td>-0.020365</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-30</th>\n",
       "      <td>0.068335</td>\n",
       "      <td>0.026815</td>\n",
       "      <td>0.000372</td>\n",
       "      <td>0.033418</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-31</th>\n",
       "      <td>0.007201</td>\n",
       "      <td>0.025077</td>\n",
       "      <td>0.000298</td>\n",
       "      <td>-0.018330</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-01</th>\n",
       "      <td>0.000481</td>\n",
       "      <td>-0.005034</td>\n",
       "      <td>-0.002380</td>\n",
       "      <td>-0.015800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-04</th>\n",
       "      <td>0.028405</td>\n",
       "      <td>0.019851</td>\n",
       "      <td>0.008128</td>\n",
       "      <td>0.028799</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-05</th>\n",
       "      <td>0.017109</td>\n",
       "      <td>0.011644</td>\n",
       "      <td>0.002663</td>\n",
       "      <td>0.013997</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-06</th>\n",
       "      <td>0.000345</td>\n",
       "      <td>-0.026841</td>\n",
       "      <td>0.005681</td>\n",
       "      <td>-0.011099</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-07</th>\n",
       "      <td>-0.018939</td>\n",
       "      <td>-0.014813</td>\n",
       "      <td>-0.011577</td>\n",
       "      <td>-0.007168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-08</th>\n",
       "      <td>0.001175</td>\n",
       "      <td>-0.003322</td>\n",
       "      <td>0.003904</td>\n",
       "      <td>0.003800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-11</th>\n",
       "      <td>-0.005751</td>\n",
       "      <td>-0.000046</td>\n",
       "      <td>0.002094</td>\n",
       "      <td>-0.003975</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-12</th>\n",
       "      <td>0.008617</td>\n",
       "      <td>0.024073</td>\n",
       "      <td>0.015374</td>\n",
       "      <td>0.015582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-13</th>\n",
       "      <td>-0.004155</td>\n",
       "      <td>-0.001079</td>\n",
       "      <td>0.010805</td>\n",
       "      <td>-0.000748</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-14</th>\n",
       "      <td>0.003643</td>\n",
       "      <td>0.001348</td>\n",
       "      <td>-0.007563</td>\n",
       "      <td>0.000843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-15</th>\n",
       "      <td>-0.002225</td>\n",
       "      <td>-0.007150</td>\n",
       "      <td>0.011357</td>\n",
       "      <td>0.012348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-19</th>\n",
       "      <td>0.002993</td>\n",
       "      <td>0.004409</td>\n",
       "      <td>0.004854</td>\n",
       "      <td>-0.000462</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-20</th>\n",
       "      <td>0.006435</td>\n",
       "      <td>-0.004255</td>\n",
       "      <td>-0.005047</td>\n",
       "      <td>-0.005199</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-21</th>\n",
       "      <td>-0.005639</td>\n",
       "      <td>-0.015111</td>\n",
       "      <td>-0.001159</td>\n",
       "      <td>0.021092</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-22</th>\n",
       "      <td>0.011166</td>\n",
       "      <td>0.012215</td>\n",
       "      <td>0.010229</td>\n",
       "      <td>0.014258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-25</th>\n",
       "      <td>0.007284</td>\n",
       "      <td>-0.000874</td>\n",
       "      <td>0.001508</td>\n",
       "      <td>0.005587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-26</th>\n",
       "      <td>0.000574</td>\n",
       "      <td>0.005165</td>\n",
       "      <td>0.001864</td>\n",
       "      <td>0.006900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-27</th>\n",
       "      <td>0.003098</td>\n",
       "      <td>0.000825</td>\n",
       "      <td>-0.003936</td>\n",
       "      <td>-0.001691</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-28</th>\n",
       "      <td>-0.009836</td>\n",
       "      <td>0.003468</td>\n",
       "      <td>-0.007473</td>\n",
       "      <td>-0.001248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-03-01</th>\n",
       "      <td>0.010511</td>\n",
       "      <td>0.018814</td>\n",
       "      <td>0.007746</td>\n",
       "      <td>0.004463</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2306 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                AAPL      GOOG       IBM      MSFT\n",
       "Date                                              \n",
       "2009-12-31       NaN       NaN       NaN       NaN\n",
       "2010-01-04  0.015565  0.010920  0.011841  0.015420\n",
       "2010-01-05  0.001729 -0.004404 -0.012080  0.000323\n",
       "2010-01-06 -0.015906 -0.025209 -0.006496 -0.006137\n",
       "2010-01-07 -0.001849 -0.023279 -0.003462 -0.010400\n",
       "2010-01-08  0.006648  0.013331  0.010035  0.006897\n",
       "2010-01-11 -0.008822 -0.001512 -0.010470 -0.012720\n",
       "2010-01-12 -0.011375 -0.017684  0.007955 -0.006607\n",
       "2010-01-13  0.014105 -0.005741 -0.002145  0.009312\n",
       "2010-01-14 -0.005791  0.004701  0.015972  0.020099\n",
       "2010-01-15 -0.016712 -0.016699 -0.004006 -0.003230\n",
       "2010-01-19  0.044238  0.013138  0.017909  0.007777\n",
       "2010-01-20 -0.015392 -0.012270 -0.028999 -0.016399\n",
       "2010-01-21 -0.017286  0.004428 -0.009597 -0.018960\n",
       "2010-01-22 -0.049599 -0.056554 -0.027132 -0.034988\n",
       "2010-01-25  0.026903 -0.018200  0.004940  0.012431\n",
       "2010-01-26  0.014133  0.004481 -0.002934  0.006139\n",
       "2010-01-27  0.009420 -0.000590  0.004612  0.005763\n",
       "2010-01-28 -0.041322 -0.014407 -0.020423 -0.017190\n",
       "2010-01-29 -0.036279 -0.008142 -0.010990 -0.033608\n",
       "2010-02-01  0.013902  0.005812  0.018629  0.008162\n",
       "2010-02-02  0.005803 -0.003565  0.006898  0.001760\n",
       "2010-02-03  0.017206  0.018263  0.001036  0.005973\n",
       "2010-02-04 -0.036039 -0.025961 -0.021168 -0.027593\n",
       "2010-02-05  0.017756  0.008562  0.004228  0.006466\n",
       "2010-02-08 -0.006855  0.004103 -0.008864 -0.010707\n",
       "2010-02-09  0.010663  0.005567  0.010912  0.010462\n",
       "2010-02-10 -0.005454 -0.003710 -0.003246 -0.000714\n",
       "2010-02-11  0.018194  0.003649  0.007491  0.004645\n",
       "2010-02-12  0.008607 -0.006115  0.002182 -0.006757\n",
       "...              ...       ...       ...       ...\n",
       "2019-01-17  0.005938  0.008261  0.004687  0.007022\n",
       "2019-01-18  0.006159  0.007670  0.013340  0.014983\n",
       "2019-01-22 -0.022446 -0.025258 -0.010499 -0.018847\n",
       "2019-01-23  0.004044  0.004717  0.084639  0.009746\n",
       "2019-01-24 -0.007926 -0.001553 -0.002709 -0.004779\n",
       "2019-01-25  0.033137  0.015914  0.010865  0.009134\n",
       "2019-01-28 -0.009255 -0.019166  0.002239 -0.019502\n",
       "2019-01-29 -0.010365 -0.008840  0.000447 -0.020365\n",
       "2019-01-30  0.068335  0.026815  0.000372  0.033418\n",
       "2019-01-31  0.007201  0.025077  0.000298 -0.018330\n",
       "2019-02-01  0.000481 -0.005034 -0.002380 -0.015800\n",
       "2019-02-04  0.028405  0.019851  0.008128  0.028799\n",
       "2019-02-05  0.017109  0.011644  0.002663  0.013997\n",
       "2019-02-06  0.000345 -0.026841  0.005681 -0.011099\n",
       "2019-02-07 -0.018939 -0.014813 -0.011577 -0.007168\n",
       "2019-02-08  0.001175 -0.003322  0.003904  0.003800\n",
       "2019-02-11 -0.005751 -0.000046  0.002094 -0.003975\n",
       "2019-02-12  0.008617  0.024073  0.015374  0.015582\n",
       "2019-02-13 -0.004155 -0.001079  0.010805 -0.000748\n",
       "2019-02-14  0.003643  0.001348 -0.007563  0.000843\n",
       "2019-02-15 -0.002225 -0.007150  0.011357  0.012348\n",
       "2019-02-19  0.002993  0.004409  0.004854 -0.000462\n",
       "2019-02-20  0.006435 -0.004255 -0.005047 -0.005199\n",
       "2019-02-21 -0.005639 -0.015111 -0.001159  0.021092\n",
       "2019-02-22  0.011166  0.012215  0.010229  0.014258\n",
       "2019-02-25  0.007284 -0.000874  0.001508  0.005587\n",
       "2019-02-26  0.000574  0.005165  0.001864  0.006900\n",
       "2019-02-27  0.003098  0.000825 -0.003936 -0.001691\n",
       "2019-02-28 -0.009836  0.003468 -0.007473 -0.001248\n",
       "2019-03-01  0.010511  0.018814  0.007746  0.004463\n",
       "\n",
       "[2306 rows x 4 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "price.pct_change()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "returns = price.pct_change()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>GOOG</th>\n",
       "      <th>IBM</th>\n",
       "      <th>MSFT</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-02-25</th>\n",
       "      <td>0.007284</td>\n",
       "      <td>-0.000874</td>\n",
       "      <td>0.001508</td>\n",
       "      <td>0.005587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-26</th>\n",
       "      <td>0.000574</td>\n",
       "      <td>0.005165</td>\n",
       "      <td>0.001864</td>\n",
       "      <td>0.006900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-27</th>\n",
       "      <td>0.003098</td>\n",
       "      <td>0.000825</td>\n",
       "      <td>-0.003936</td>\n",
       "      <td>-0.001691</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-28</th>\n",
       "      <td>-0.009836</td>\n",
       "      <td>0.003468</td>\n",
       "      <td>-0.007473</td>\n",
       "      <td>-0.001248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-03-01</th>\n",
       "      <td>0.010511</td>\n",
       "      <td>0.018814</td>\n",
       "      <td>0.007746</td>\n",
       "      <td>0.004463</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                AAPL      GOOG       IBM      MSFT\n",
       "Date                                              \n",
       "2019-02-25  0.007284 -0.000874  0.001508  0.005587\n",
       "2019-02-26  0.000574  0.005165  0.001864  0.006900\n",
       "2019-02-27  0.003098  0.000825 -0.003936 -0.001691\n",
       "2019-02-28 -0.009836  0.003468 -0.007473 -0.001248\n",
       "2019-03-01  0.010511  0.018814  0.007746  0.004463"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.48668310978790741"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns['MSFT'].corr(returns['IBM'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8.7347189057950138e-05"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns['MSFT'].cov(returns['IBM'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>GOOG</th>\n",
       "      <th>IBM</th>\n",
       "      <th>MSFT</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AAPL</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.457481</td>\n",
       "      <td>0.372080</td>\n",
       "      <td>0.450247</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GOOG</th>\n",
       "      <td>0.457481</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.408324</td>\n",
       "      <td>0.537512</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>IBM</th>\n",
       "      <td>0.372080</td>\n",
       "      <td>0.408324</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.486683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MSFT</th>\n",
       "      <td>0.450247</td>\n",
       "      <td>0.537512</td>\n",
       "      <td>0.486683</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          AAPL      GOOG       IBM      MSFT\n",
       "AAPL  1.000000  0.457481  0.372080  0.450247\n",
       "GOOG  0.457481  1.000000  0.408324  0.537512\n",
       "IBM   0.372080  0.408324  1.000000  0.486683\n",
       "MSFT  0.450247  0.537512  0.486683  1.000000"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.corr()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>GOOG</th>\n",
       "      <th>IBM</th>\n",
       "      <th>MSFT</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AAPL</th>\n",
       "      <td>0.000271</td>\n",
       "      <td>0.000116</td>\n",
       "      <td>0.000076</td>\n",
       "      <td>0.000108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GOOG</th>\n",
       "      <td>0.000116</td>\n",
       "      <td>0.000238</td>\n",
       "      <td>0.000078</td>\n",
       "      <td>0.000121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>IBM</th>\n",
       "      <td>0.000076</td>\n",
       "      <td>0.000078</td>\n",
       "      <td>0.000153</td>\n",
       "      <td>0.000087</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MSFT</th>\n",
       "      <td>0.000108</td>\n",
       "      <td>0.000121</td>\n",
       "      <td>0.000087</td>\n",
       "      <td>0.000211</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          AAPL      GOOG       IBM      MSFT\n",
       "AAPL  0.000271  0.000116  0.000076  0.000108\n",
       "GOOG  0.000116  0.000238  0.000078  0.000121\n",
       "IBM   0.000076  0.000078  0.000153  0.000087\n",
       "MSFT  0.000108  0.000121  0.000087  0.000211"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.cov()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AAPL    0.372080\n",
       "GOOG    0.408324\n",
       "IBM     1.000000\n",
       "MSFT    0.486683\n",
       "dtype: float64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.corrwith(returns.IBM)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>GOOG</th>\n",
       "      <th>IBM</th>\n",
       "      <th>MSFT</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2009-12-31</th>\n",
       "      <td>88102700.0</td>\n",
       "      <td>2455400.0</td>\n",
       "      <td>4223400.0</td>\n",
       "      <td>31929700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-04</th>\n",
       "      <td>123432400.0</td>\n",
       "      <td>3937800.0</td>\n",
       "      <td>6155300.0</td>\n",
       "      <td>38409100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-05</th>\n",
       "      <td>150476200.0</td>\n",
       "      <td>6048500.0</td>\n",
       "      <td>6841400.0</td>\n",
       "      <td>49749600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-06</th>\n",
       "      <td>138040000.0</td>\n",
       "      <td>8009000.0</td>\n",
       "      <td>5605300.0</td>\n",
       "      <td>58182400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-07</th>\n",
       "      <td>119282800.0</td>\n",
       "      <td>12912000.0</td>\n",
       "      <td>5840600.0</td>\n",
       "      <td>50559700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-08</th>\n",
       "      <td>111902700.0</td>\n",
       "      <td>9509900.0</td>\n",
       "      <td>4197200.0</td>\n",
       "      <td>51197400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-11</th>\n",
       "      <td>115557400.0</td>\n",
       "      <td>14519600.0</td>\n",
       "      <td>5730400.0</td>\n",
       "      <td>68754700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-12</th>\n",
       "      <td>148614900.0</td>\n",
       "      <td>9769600.0</td>\n",
       "      <td>8081500.0</td>\n",
       "      <td>65912100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-13</th>\n",
       "      <td>151473000.0</td>\n",
       "      <td>13077600.0</td>\n",
       "      <td>6455400.0</td>\n",
       "      <td>51863500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-14</th>\n",
       "      <td>108223500.0</td>\n",
       "      <td>8535300.0</td>\n",
       "      <td>7111800.0</td>\n",
       "      <td>63228100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-15</th>\n",
       "      <td>148516900.0</td>\n",
       "      <td>10939600.0</td>\n",
       "      <td>8494400.0</td>\n",
       "      <td>79913200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-19</th>\n",
       "      <td>182501900.0</td>\n",
       "      <td>8689500.0</td>\n",
       "      <td>13916200.0</td>\n",
       "      <td>46575700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-20</th>\n",
       "      <td>153038200.0</td>\n",
       "      <td>6543600.0</td>\n",
       "      <td>15197500.0</td>\n",
       "      <td>54849500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-21</th>\n",
       "      <td>152038600.0</td>\n",
       "      <td>12697400.0</td>\n",
       "      <td>9608600.0</td>\n",
       "      <td>73086700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-22</th>\n",
       "      <td>220441900.0</td>\n",
       "      <td>13689200.0</td>\n",
       "      <td>10088600.0</td>\n",
       "      <td>102004600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-25</th>\n",
       "      <td>266424900.0</td>\n",
       "      <td>8897200.0</td>\n",
       "      <td>5738500.0</td>\n",
       "      <td>63373000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-26</th>\n",
       "      <td>466777500.0</td>\n",
       "      <td>8767600.0</td>\n",
       "      <td>7135300.0</td>\n",
       "      <td>66639900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-27</th>\n",
       "      <td>430642100.0</td>\n",
       "      <td>7980200.0</td>\n",
       "      <td>8719200.0</td>\n",
       "      <td>63949500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-28</th>\n",
       "      <td>293375600.0</td>\n",
       "      <td>6500100.0</td>\n",
       "      <td>9622200.0</td>\n",
       "      <td>117513700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-29</th>\n",
       "      <td>311488100.0</td>\n",
       "      <td>8334700.0</td>\n",
       "      <td>11571200.0</td>\n",
       "      <td>193888500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-01</th>\n",
       "      <td>187469100.0</td>\n",
       "      <td>4530800.0</td>\n",
       "      <td>7242900.0</td>\n",
       "      <td>85931100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-02</th>\n",
       "      <td>174585600.0</td>\n",
       "      <td>8245600.0</td>\n",
       "      <td>5899900.0</td>\n",
       "      <td>54413700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-03</th>\n",
       "      <td>153832000.0</td>\n",
       "      <td>6037000.0</td>\n",
       "      <td>4177100.0</td>\n",
       "      <td>61397900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-04</th>\n",
       "      <td>189413000.0</td>\n",
       "      <td>6799200.0</td>\n",
       "      <td>9126900.0</td>\n",
       "      <td>77850000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-05</th>\n",
       "      <td>212576700.0</td>\n",
       "      <td>6353000.0</td>\n",
       "      <td>8617000.0</td>\n",
       "      <td>80960100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-08</th>\n",
       "      <td>119567700.0</td>\n",
       "      <td>5423500.0</td>\n",
       "      <td>5718500.0</td>\n",
       "      <td>52820600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-09</th>\n",
       "      <td>158221700.0</td>\n",
       "      <td>5675700.0</td>\n",
       "      <td>6044500.0</td>\n",
       "      <td>59195800.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-10</th>\n",
       "      <td>92590400.0</td>\n",
       "      <td>5383700.0</td>\n",
       "      <td>5219100.0</td>\n",
       "      <td>48591300.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-11</th>\n",
       "      <td>137586400.0</td>\n",
       "      <td>4851300.0</td>\n",
       "      <td>5089000.0</td>\n",
       "      <td>65993700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-02-12</th>\n",
       "      <td>163867200.0</td>\n",
       "      <td>4589000.0</td>\n",
       "      <td>8017700.0</td>\n",
       "      <td>81117200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-17</th>\n",
       "      <td>29821200.0</td>\n",
       "      <td>1242700.0</td>\n",
       "      <td>5029900.0</td>\n",
       "      <td>28393000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-18</th>\n",
       "      <td>33751000.0</td>\n",
       "      <td>1955600.0</td>\n",
       "      <td>6008500.0</td>\n",
       "      <td>37427600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-22</th>\n",
       "      <td>30394000.0</td>\n",
       "      <td>1613500.0</td>\n",
       "      <td>10052400.0</td>\n",
       "      <td>32371300.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-23</th>\n",
       "      <td>23130600.0</td>\n",
       "      <td>967000.0</td>\n",
       "      <td>22063700.0</td>\n",
       "      <td>25874300.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-24</th>\n",
       "      <td>25441500.0</td>\n",
       "      <td>1361300.0</td>\n",
       "      <td>6322900.0</td>\n",
       "      <td>23164800.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-25</th>\n",
       "      <td>33535500.0</td>\n",
       "      <td>1119100.0</td>\n",
       "      <td>5707400.0</td>\n",
       "      <td>31225600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-28</th>\n",
       "      <td>26192100.0</td>\n",
       "      <td>1284300.0</td>\n",
       "      <td>5357700.0</td>\n",
       "      <td>29476700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-29</th>\n",
       "      <td>41587200.0</td>\n",
       "      <td>1021800.0</td>\n",
       "      <td>5037100.0</td>\n",
       "      <td>31490500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-30</th>\n",
       "      <td>61109800.0</td>\n",
       "      <td>1279800.0</td>\n",
       "      <td>4500900.0</td>\n",
       "      <td>49471900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-31</th>\n",
       "      <td>40739600.0</td>\n",
       "      <td>1538300.0</td>\n",
       "      <td>4884000.0</td>\n",
       "      <td>55636400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-01</th>\n",
       "      <td>32668100.0</td>\n",
       "      <td>1462200.0</td>\n",
       "      <td>3806000.0</td>\n",
       "      <td>35535700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-04</th>\n",
       "      <td>31495500.0</td>\n",
       "      <td>2576500.0</td>\n",
       "      <td>3966600.0</td>\n",
       "      <td>31315100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-05</th>\n",
       "      <td>36101600.0</td>\n",
       "      <td>3552200.0</td>\n",
       "      <td>5398900.0</td>\n",
       "      <td>27325400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-06</th>\n",
       "      <td>28239600.0</td>\n",
       "      <td>2105600.0</td>\n",
       "      <td>4879700.0</td>\n",
       "      <td>20609800.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-07</th>\n",
       "      <td>31741700.0</td>\n",
       "      <td>2044800.0</td>\n",
       "      <td>4379400.0</td>\n",
       "      <td>29760700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-08</th>\n",
       "      <td>23820000.0</td>\n",
       "      <td>1075800.0</td>\n",
       "      <td>3249800.0</td>\n",
       "      <td>21461100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-11</th>\n",
       "      <td>20993400.0</td>\n",
       "      <td>1065200.0</td>\n",
       "      <td>3095100.0</td>\n",
       "      <td>18914100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-12</th>\n",
       "      <td>22283500.0</td>\n",
       "      <td>1609100.0</td>\n",
       "      <td>3317200.0</td>\n",
       "      <td>25056600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-13</th>\n",
       "      <td>22490200.0</td>\n",
       "      <td>1049800.0</td>\n",
       "      <td>4253000.0</td>\n",
       "      <td>18394900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-14</th>\n",
       "      <td>21835700.0</td>\n",
       "      <td>947600.0</td>\n",
       "      <td>2789400.0</td>\n",
       "      <td>21784700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-15</th>\n",
       "      <td>24626800.0</td>\n",
       "      <td>1449800.0</td>\n",
       "      <td>3844100.0</td>\n",
       "      <td>26606900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-19</th>\n",
       "      <td>18972800.0</td>\n",
       "      <td>1046400.0</td>\n",
       "      <td>3385700.0</td>\n",
       "      <td>18038500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-20</th>\n",
       "      <td>26114400.0</td>\n",
       "      <td>1087800.0</td>\n",
       "      <td>3802000.0</td>\n",
       "      <td>21607700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-21</th>\n",
       "      <td>17249700.0</td>\n",
       "      <td>1415100.0</td>\n",
       "      <td>2937300.0</td>\n",
       "      <td>29063200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-22</th>\n",
       "      <td>18913200.0</td>\n",
       "      <td>1049500.0</td>\n",
       "      <td>3113700.0</td>\n",
       "      <td>27763200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-25</th>\n",
       "      <td>21873400.0</td>\n",
       "      <td>1413100.0</td>\n",
       "      <td>3194200.0</td>\n",
       "      <td>23750600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-26</th>\n",
       "      <td>17070200.0</td>\n",
       "      <td>1471300.0</td>\n",
       "      <td>3060400.0</td>\n",
       "      <td>21536700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-27</th>\n",
       "      <td>27835400.0</td>\n",
       "      <td>968400.0</td>\n",
       "      <td>2530900.0</td>\n",
       "      <td>21487100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-28</th>\n",
       "      <td>28215400.0</td>\n",
       "      <td>1542500.0</td>\n",
       "      <td>3457800.0</td>\n",
       "      <td>29083900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-03-01</th>\n",
       "      <td>25873500.0</td>\n",
       "      <td>1449800.0</td>\n",
       "      <td>2979600.0</td>\n",
       "      <td>20827800.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2306 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                   AAPL        GOOG         IBM         MSFT\n",
       "Date                                                        \n",
       "2009-12-31   88102700.0   2455400.0   4223400.0   31929700.0\n",
       "2010-01-04  123432400.0   3937800.0   6155300.0   38409100.0\n",
       "2010-01-05  150476200.0   6048500.0   6841400.0   49749600.0\n",
       "2010-01-06  138040000.0   8009000.0   5605300.0   58182400.0\n",
       "2010-01-07  119282800.0  12912000.0   5840600.0   50559700.0\n",
       "2010-01-08  111902700.0   9509900.0   4197200.0   51197400.0\n",
       "2010-01-11  115557400.0  14519600.0   5730400.0   68754700.0\n",
       "2010-01-12  148614900.0   9769600.0   8081500.0   65912100.0\n",
       "2010-01-13  151473000.0  13077600.0   6455400.0   51863500.0\n",
       "2010-01-14  108223500.0   8535300.0   7111800.0   63228100.0\n",
       "2010-01-15  148516900.0  10939600.0   8494400.0   79913200.0\n",
       "2010-01-19  182501900.0   8689500.0  13916200.0   46575700.0\n",
       "2010-01-20  153038200.0   6543600.0  15197500.0   54849500.0\n",
       "2010-01-21  152038600.0  12697400.0   9608600.0   73086700.0\n",
       "2010-01-22  220441900.0  13689200.0  10088600.0  102004600.0\n",
       "2010-01-25  266424900.0   8897200.0   5738500.0   63373000.0\n",
       "2010-01-26  466777500.0   8767600.0   7135300.0   66639900.0\n",
       "2010-01-27  430642100.0   7980200.0   8719200.0   63949500.0\n",
       "2010-01-28  293375600.0   6500100.0   9622200.0  117513700.0\n",
       "2010-01-29  311488100.0   8334700.0  11571200.0  193888500.0\n",
       "2010-02-01  187469100.0   4530800.0   7242900.0   85931100.0\n",
       "2010-02-02  174585600.0   8245600.0   5899900.0   54413700.0\n",
       "2010-02-03  153832000.0   6037000.0   4177100.0   61397900.0\n",
       "2010-02-04  189413000.0   6799200.0   9126900.0   77850000.0\n",
       "2010-02-05  212576700.0   6353000.0   8617000.0   80960100.0\n",
       "2010-02-08  119567700.0   5423500.0   5718500.0   52820600.0\n",
       "2010-02-09  158221700.0   5675700.0   6044500.0   59195800.0\n",
       "2010-02-10   92590400.0   5383700.0   5219100.0   48591300.0\n",
       "2010-02-11  137586400.0   4851300.0   5089000.0   65993700.0\n",
       "2010-02-12  163867200.0   4589000.0   8017700.0   81117200.0\n",
       "...                 ...         ...         ...          ...\n",
       "2019-01-17   29821200.0   1242700.0   5029900.0   28393000.0\n",
       "2019-01-18   33751000.0   1955600.0   6008500.0   37427600.0\n",
       "2019-01-22   30394000.0   1613500.0  10052400.0   32371300.0\n",
       "2019-01-23   23130600.0    967000.0  22063700.0   25874300.0\n",
       "2019-01-24   25441500.0   1361300.0   6322900.0   23164800.0\n",
       "2019-01-25   33535500.0   1119100.0   5707400.0   31225600.0\n",
       "2019-01-28   26192100.0   1284300.0   5357700.0   29476700.0\n",
       "2019-01-29   41587200.0   1021800.0   5037100.0   31490500.0\n",
       "2019-01-30   61109800.0   1279800.0   4500900.0   49471900.0\n",
       "2019-01-31   40739600.0   1538300.0   4884000.0   55636400.0\n",
       "2019-02-01   32668100.0   1462200.0   3806000.0   35535700.0\n",
       "2019-02-04   31495500.0   2576500.0   3966600.0   31315100.0\n",
       "2019-02-05   36101600.0   3552200.0   5398900.0   27325400.0\n",
       "2019-02-06   28239600.0   2105600.0   4879700.0   20609800.0\n",
       "2019-02-07   31741700.0   2044800.0   4379400.0   29760700.0\n",
       "2019-02-08   23820000.0   1075800.0   3249800.0   21461100.0\n",
       "2019-02-11   20993400.0   1065200.0   3095100.0   18914100.0\n",
       "2019-02-12   22283500.0   1609100.0   3317200.0   25056600.0\n",
       "2019-02-13   22490200.0   1049800.0   4253000.0   18394900.0\n",
       "2019-02-14   21835700.0    947600.0   2789400.0   21784700.0\n",
       "2019-02-15   24626800.0   1449800.0   3844100.0   26606900.0\n",
       "2019-02-19   18972800.0   1046400.0   3385700.0   18038500.0\n",
       "2019-02-20   26114400.0   1087800.0   3802000.0   21607700.0\n",
       "2019-02-21   17249700.0   1415100.0   2937300.0   29063200.0\n",
       "2019-02-22   18913200.0   1049500.0   3113700.0   27763200.0\n",
       "2019-02-25   21873400.0   1413100.0   3194200.0   23750600.0\n",
       "2019-02-26   17070200.0   1471300.0   3060400.0   21536700.0\n",
       "2019-02-27   27835400.0    968400.0   2530900.0   21487100.0\n",
       "2019-02-28   28215400.0   1542500.0   3457800.0   29083900.0\n",
       "2019-03-01   25873500.0   1449800.0   2979600.0   20827800.0\n",
       "\n",
       "[2306 rows x 4 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "volume"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AAPL   -0.059732\n",
       "GOOG   -0.017377\n",
       "IBM    -0.153277\n",
       "MSFT   -0.089666\n",
       "dtype: float64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.corrwith(volume,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obj = pd.Series(['c', 'a', 'd', 'a', 'a', 'b', 'b', 'c',\n",
    "'c'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    c\n",
       "1    a\n",
       "2    d\n",
       "3    a\n",
       "4    a\n",
       "5    b\n",
       "6    b\n",
       "7    c\n",
       "8    c\n",
       "dtype: object"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "uniques = obj.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['c', 'a', 'd', 'b'], dtype=object)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "uniques"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "c    3\n",
       "a    3\n",
       "b    2\n",
       "d    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "c    3\n",
       "a    3\n",
       "b    2\n",
       "d    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.value_counts(obj,sort=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "mask = obj.isin(['b','c'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1    False\n",
       "2    False\n",
       "3    False\n",
       "4    False\n",
       "5     True\n",
       "6     True\n",
       "7     True\n",
       "8     True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    c\n",
       "5    b\n",
       "6    b\n",
       "7    c\n",
       "8    c\n",
       "dtype: object"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj[mask]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "to_match = pd.Series(['c', 'a', 'b', 'b', 'c', 'a'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "unique_vals = pd.Series(['c', 'b', 'a'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 2, 1, 1, 0, 2], dtype=int64)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Index(unique_vals).get_indexer(to_match)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = pd.DataFrame({'Qu1': [1, 3, 4, 3, 4],\n",
    "'Qu2': [2, 3, 1, 2, 3],\n",
    "'Qu3': [1, 5, 2, 4, 4]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Qu1</th>\n",
       "      <th>Qu2</th>\n",
       "      <th>Qu3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Qu1  Qu2  Qu3\n",
       "0    1    2    1\n",
       "1    3    3    5\n",
       "2    4    1    2\n",
       "3    3    2    4\n",
       "4    4    3    4"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "result = data.apply(pd.value_counts).fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Qu1</th>\n",
       "      <th>Qu2</th>\n",
       "      <th>Qu3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Qu1  Qu2  Qu3\n",
       "1  1.0  1.0  1.0\n",
       "2  0.0  2.0  1.0\n",
       "3  2.0  2.0  0.0\n",
       "4  2.0  0.0  2.0\n",
       "5  0.0  0.0  1.0"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
